package com.yan.demo;

public class MethodTest5 {
    public static void main(String[] args) {
        int[] scores = {97, 96, 98, 99, 90, 95};
        double grade = newArr(scores);
        System.out.println(grade);
    }

    public static double newArr(int[] arr) {
        double sum = 0.0;
        double avg = 0.0;
        int min = arr[0];
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
            if (arr[i] < min) {
                min = arr[i];
            }
            sum += arr[i];
        }
        sum = sum - max - min;
        avg = sum / (arr.length - 2);
        return avg;
    }
}
